<template>
    <view class="pub_page pub_page_bg_big pub_team pub_header_padding">
        <pub-head headerName="team" :headerConfig="headerConfig"></pub-head>
        <z-paging ref="Zpaging" class="pub_page_scroll page_box" v-model="list" @query="getList"
            :refresher-enabled="false" :show-loading-more-no-more-view="false" :fixed="false" :hide-empty-view="true">
            <div class="page_div" v-if="teamInfo">
                <div class="info_div">
                    <div class="li_1">兑换券：<span class="num">+{{ teamInfo.totalShareExReward || 0 }}</span></div>
                    <div class="li_1">今日奖励：<span class="num">+{{ teamInfo.shareExReward || 0 }}</span></div>
                    <div class="li_2">
                        <div class="num">
                            <div class="p_1">大区活跃会员</div>
                            <div class="p_2">{{ teamInfo.maxActiveNum || 0 }}</div>
                        </div>
                        <div class="num">
                            <div class="p_1">小区活跃会员</div>
                            <div class="p_2">{{ teamInfo.minActiveNum || 0 }}</div>
                        </div>
                        <div class="num">
                            <div class="p_1">销售业绩</div>
                            <div class="p_2">{{ teamInfo.minTeamMoney || 0 }}</div>
                        </div>
                    </div>
                </div>
                <div class="team_div">
                    <div class="lis_div" v-if="teamInfo.superior">
                        <div class="title">我的推荐人</div>
                        <div class="li">
                            <pub-image class="headimg" :src="teamInfo.superior.avatar" mode="aspectFill" />
                            <div class="span">
                                <div class="span_0">{{ teamInfo.superior.nickName }}</div>
                                <div class="span_1" v-if="teamInfo.superior.isActive">有效会员</div>
                            </div>
                            <div class="txt">{{ teamInfo.superior.mobile }}</div>
                        </div>
                        <br>
                    </div>
                    <div class="lis_div">
                        <div class="title">直推列表</div>
                        <div class="li" v-for="(li, key) in list" :key="key">
                            <pub-image class="headimg" :src="li.avatar" mode="aspectFill" />
                            <div class="span">
                                <div class="span_0">{{ li.nickName }}</div>
                                <div class="span_1" v-if="li.isActive">有效会员</div>
                            </div>
                            <div class="txt">{{ li.mobile }}</div>
                        </div>
                        <div class="pub_nodata_1" v-if="list.length==0">暂无数据</div>
                    </div>
                </div>
            </div>
        </z-paging>
    </view>
</template>

<script>
export default {
    data() {
        return {
            pagescrollTop: 0,
            headerConfig: {
                title: '我的团队',//标题栏内容
                left_type: 3,
                title_color: '#000',
                left_content: 'dark',
                header_color: '#fff'
            },

            teamInfo: '',
            userInfo: '',
            list: []
        };
    },
    onLoad() {
        this.getTeamInfo();
        // this.getInfo();
        setTimeout(() => {
            this.$refs.Zpaging.reload()
        }, 400);
    },
    onPageScroll(res) {
        this.pagescrollTop = res.scrollTop;
    },
    methods: {
        async getInfo() {
            const res = await this.$request.get('user/userInfo', {});
            if (res.code == 200) {
                this.userInfo = res.result;
            }
        },
        async getTeamInfo() {
            this.$comFun.openLoading();
            const res = await this.$request.get('user/myTeam', {});
            // console.log(res);
            this.$comFun.closeLoading();
            if (res.code == 200) {
                this.teamInfo = res.result;
            }
        },
        async getList(pageNo, pageSize) {
            const res = await this.$request.get('user/myChildPage', {
                pageNo: pageNo,
                pageSize: pageSize,
            });
            this.$comFun.closeLoading();
            // console.log(res);
            if (res.code == 200) {
                this.$refs.Zpaging.complete(res.result.records);
            } else {
                this.$refs.Zpaging.complete(false);
            }
        }
    },
};
</script>

<style lang="scss" scoped>
@import "@/common/css/mine.scss";
</style>
